{extend name='common/content' /}

{block name="content"}
<div class="admin-main layui-anim layui-anim-upbit">
    <!-- <fieldset class="layui-elem-field layui-field-title">
        <legend>{$title}</legend>
    </fieldset>
 -->    

    {if condition="in_array(1, explode(',', session('user.authorize')))"}
    <blockquote class="layui-elem-quote">
        <a data-open='{:url("$classuri/add")}' class="layui-btn layui-btn-sm">{:lang('add')}分类</a>
    </blockquote>
    {/if}

    <table class="layui-table">
        <thead>
        <tr>
            <th>编号</th>
            <th>分类名称<span id="cateNameMsg">(点击查看内容)</span></th>
            <th>分类模型</th>
            <th>导航</th>
            {if condition="in_array(1, explode(',', session('user.authorize')))"}
            <th>{:lang('order')}</th>
            <th>操作</th>
            {/if}
            
        </tr>
        </thead>
        <?php if(empty($categorys)){?>
            <tbody id="con"></tbody>
        <?php }else{?>
            <tbody id="con">{$categorys}</tbody>
        <?php }?>
        <tfoot>
    </table>
</div>

<!-- <script src="__STATIC__/common/js/jquery.2.1.1.min.js"></script> -->
<script>
    layui.use('table', function(){
        var $= layui.jquery;
        $('body').on('blur','.list_order',function() {
            var id = $(this).attr('data-id');
            var sort = $(this).val();
            var loading = layer.load(1, {shade: [0.1, '#fff']});
            $.post('{:url("cOrder")}',{id:id,sort:sort},function(res){
                layer.close(loading);
                if(res.code === 1){
                    layer.msg(res.msg, {time: 1000, icon: 1}, function () {
                        location.href = res.url;
                    });
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            })
        });
    });
    function del(id) {
        layer.confirm('你确定要删除该分类及其子分类吗？', {icon: 3}, function (index) {
            $.post('{:url("del")}', {id: id}, function (data) {
                if (data.status === 1) {
                    layer.alert(data.info, {icon: 6}, function(index){
                        layer.close(index);
                        window.location.href=data.url;
                    });
                }else{
                    layer.msg(data.info,{icon:5});
                }
            });
            layer.close(index);
        });
    }
</script>
{/block} 
